#include <cstdio>
#include <algorithm>

using namespace std; 
 
#define N 10001
#define K 10001

struct task_t {
	int start, last; 
}; 

task_t tsk[K]; 
int n, k; 

int start_num[N]; 
int pos=0; 
int f[N]; 

bool cmp_s(task_t &a, task_t &b)
{
	return a.start > b.start; 
}

int main()
{
	int i, j; 
	
	//freopen("p1280_2.in", "r", stdin); 
	scanf("%d %d", &n, &k); 
	for (i=0; i<k; i++) {
		scanf("%d %d", &tsk[i].start, &tsk[i].last); 
		start_num[tsk[i].start]++; 
	}

	sort(tsk, tsk+k, cmp_s); 

	for (i=n; i>=1; i--) {
		if (start_num[i]==0) {
			f[i] = f[i+1] + 1; 
		} else {
			for (j=0; j<start_num[i]; j++) {
				f[i] = max(f[i], f[i+tsk[pos].last]); 
				pos++; 
			}
		}
	}
	
	printf("%d\n", f[1]); 
	return 0; 
}



